package com.supermap.common.dao;

import com.supermap.common.entity.Crop;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author:langhongshuai
 * @Description:作物数据访问层
 * @Date:18/1/8 上午11:36
 */
@Repository
@Mapper
public interface CropDao {

    /**
     * 获得所有的作物信息
     * @return
     */
    @Select("select * from t_crop where levels=#{levels}")
    public List<Crop> getAllCropByLevels(@Param("levels")int levels);

    /**
     * 获得所有的作物信息的等级信息
     * @return
     */
    @Select("select * from t_crop")
    public List<Crop> getAllCrop();

    /**
     * 插入作物信息
     * @param crop
     */
    @Insert("insert t_crop(id,sys_org_code,sys_company_code,code,name,description,levels,root_code,parentid,sequence) values("
            + "#{Crop.id},#{Crop.sys_org_code},#{Crop.sys_company_code},#{Crop.code},#{Crop.name},"
            + "#{Crop.description},#{Crop.levels},#{Crop.root_code},#{Crop.parentid},#{Crop.sequence})")
    public void saveCrop(@Param("Crop") Crop crop);

    /**
     * 更新作物信息
     * @param crop
     */
    @Update("update t_crop set sys_org_code=#{Crop.sys_org_code},sys_company_code=#{Crop.sys_company_code},code=#{Crop.code},"
            + "name=#{Crop.name},description=#{Crop.description},levels=#{Crop.levels},root_code=#{Crop.root_code},"
            + "parentid=#{Crop.parentid},sequence=#{Crop.sequence} where id=#{Crop.id}")
    public void updateCrop(@Param("Crop") Crop crop);

    /**
     * 删除作物信息
     * @param id
     */
    @Delete("delete from t_crop where id=#{id} ")
    public void deleteCrop(@Param("id") String id);

}
